const DEBUG_MODE = process.env.NODE_ENV === 'development'
const {bptDomain} = new URL(`../../env.json`, import.meta.url).href

// let serverPath = ''

// 后端服务器链接
// const local = window.location.origin
// let serverUrl = ''
// if (local.includes('localhost')) {
//   serverUrl = 'https://it.zmylclould.com:18089/'
//   serverPath = 'dev'
// } else if (local.includes('-test') || local.includes('177.19.120') || local.includes('192.168.42')) {
//   serverUrl = 'https://it.zmylclould.com:18089/'
//   serverPath = 'test'
// } else {
//   serverUrl = ''
//   serverPath = 'prod'
// }

// oss 链接
const oss = {
  url: '',
  last: '?x-oss-process=style/small'
}

const dateFormat = (fmt, date) => {
  let ret;
  const opt = {
      "Y+": date.getFullYear().toString(),        // 年
      "M+": (date.getMonth() + 1).toString(),     // 月
      "D+": date.getDate().toString(),            // 日
      "h+": date.getHours().toString(),           // 时
      "m+": date.getMinutes().toString(),         // 分
      "s+": date.getSeconds().toString()          // 秒
      // 有其他格式化字符需求可以继续添加，必须转化成字符串
  }
  for (let k in opt) {
      ret = new RegExp("(" + k + ")").exec(fmt)
      if (ret) {
          fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
      }
  }
  return fmt
}

export { DEBUG_MODE, bptDomain, oss, dateFormat }
